from pages.base_page import BasePage
from selenium.webdriver.common.by import By


class FirstViewCluePage(BasePage):
    url = "/crm/index.php?m=leads&a=add"
    communication_log_locator = (By.XPATH,'/html/body/div[5]/div/div[1]/ul/li[3]/a')
    add_communication_log_locator = (By.LINK_TEXT,'添加')
    add_subject_log_locator = (By.ID,'subject')
    add_btn_log_locator = (By.CSS_SELECTOR,'#dialog-log > form > table > tbody > tr:nth-child(5) > td:nth-child(2) > input.btn.btn-primary')
    add_log_succeed_locator = (By.CSS_SELECTOR,'#tab1 > div.back_box > div')
    add_log_time_locator = (By.CSS_SELECTOR,'#nextstep_time')
    cancel_add_log_locator = (By.CSS_SELECTOR,'#dialog-log > form > table > tbody > tr:nth-child(5) > td:nth-child(2) > input:nth-child(2)')
    cancel_add_log_succeed_locator = (By.CSS_SELECTOR,'#tab2 > div.header1 > div.pull-left.two-title')
    delete_communication_log_locator = (By.CSS_SELECTOR,'/html/body/div[5]/div/div[2]/div[2]/div[4]/a[2]')
    #点击线索详情的沟通日志
    def click_communication_log(self):
        self.driver.find_element(*self.communication_log_locator).click()
    #点击线索详情的添加沟通日志
    def add_communication_log(self):
        self.driver.find_element(*self.add_communication_log_locator).click()

    #输入沟通日志的主题
    def add_subject_log(self,subject):
        self.driver.find_element(*self.add_subject_log_locator).send_keys(subject)
    #点击沟通日志的保存按钮
    def add_btn_log(self):
        self.driver.find_element(*self.add_btn_log_locator).click()
    #返回添加沟通日志成功的提示信息
    def add_log_succeed(self):
        return self.driver.find_element(*self.add_log_succeed_locator).text
    #添加日志的时间
    def add_log_time(self,log_time):
        self.driver.find_element(*self.add_log_time_locator).send_keys(log_time)
    #点击沟通日志的取消按钮
    def cancel_add_log(self):
        self.driver.find_element(*self.cancel_add_log_locator).click()
    #返回取消添加沟通日志成功的提示信息
    def cancel_add_log_succeed(self):
        return self.driver.find_element(*self.cancel_add_log_succeed_locator).text
    #点击删除沟通日志
    def delete_communication_log(self):
        self.driver.find_element(*self.delete_communication_log_locator).click()




